//package com.ruizhong.centercontroll.util;
//
//import org.vosk.LibVosk;
//import org.vosk.LogLevel;
//import org.vosk.Model;
//import org.vosk.Recognizer;
//
//import javax.sound.sampled.AudioSystem;
//import javax.sound.sampled.UnsupportedAudioFileException;
//import java.io.*;
//
//public class VoiceToTextUtil {
//
//    public static void execModel(InputStream inputStream) throws IOException {
//        LibVosk.setLogLevel(LogLevel.DEBUG);
//
//        try (
//                Model model = new Model("./vosk-model-small-cn-0.22");
//                InputStream ais =
////                        AudioSystem.getAudioInputStream(new BufferedInputStream(new FileInputStream("C:\\Users\\fengweijie\\Downloads\\girlVoice\\00.wav")));
//                        AudioSystem.getAudioInputStream(new BufferedInputStream(new FileInputStream("temp.wav")));
//                Recognizer recognizer = new Recognizer(model, 16000)
//        ) {
//
//            int bytes;
//            byte[] b = new byte[4096];
//            while ((bytes = ais.read(b)) >= 0) {
//                recognizer.acceptWaveForm(b, bytes);
//            }
//
//            System.out.println(recognizer.getFinalResult() + System.lineSeparator());
//        } catch (UnsupportedAudioFileException e) {
//            e.printStackTrace();
//        }
//
//    }
//
//}
